#include "Julia4.h"

#include "util.h"
#include "shader.h"
#include "gl_util.h"

#include <boost/shared_ptr.hpp>

namespace fractals {
	Julia4::Julia4(float velocity) 
		: ShaderFractal4d("julia4.sl"), 
		velocity(velocity), 
		w(1), 
		vw(-velocity),
		start(ms())
	{
	}

	void Julia4::draw(bool &didClear) {
		ShaderFractal::draw(didClear);

		if(w < -2 || w > 2)
		{
			vw=-vw;

			long now=ms();
			long delta=now - start;
			start=now;

			cout << "Pass took " << delta << "ms" << endl;
		}

		w += vw;

		use(shader()) {
			shader().setUniform("epsilon", pitch() / 2);
			shader().setUniform("w", w);
		}
	}
}
